-- @owner: zou_jialiang050
-- @date: 2024-07-06
-- @testpoint: union/union all的测试

--step1:建表;expect:成功
drop sequence if exists seq_ustore_regr_sxy_010 cascade;
create sequence seq_ustore_regr_sxy_010 increment by 1 start with 10;
drop table if exists t_ustore_regr_sxy_010 cascade;
create table  t_ustore_regr_sxy_010(
     col_1 integer,
     col_2 number(19,0),
     col_3 number(10,6)
) with (storage_type=ustore);

begin
	for i in 1..50 loop
      insert into t_ustore_regr_sxy_010 values(
	  i,
      seq_ustore_regr_sxy_010.nextval,
	  i+445.255
	  );
    end loop;
end;
/

--step2:union/union all的测试;expect:成功
select * from (
select distinct REGR_sxy(COL_1,COL_2) from t_ustore_regr_sxy_010 group by COL_1
union all
select REGR_sxy(COL_1,COL_1) from t_ustore_regr_sxy_010
union
select REGR_sxy(distinct COL_2,COL_2) from t_ustore_regr_sxy_010
minus
select REGR_sxy(COL_2,COL_3) from t_ustore_regr_sxy_010) order by 1 limit 10;

select * from (
select distinct REGR_sxy(COL_1,COL_2) from t_ustore_regr_sxy_010 group by COL_1
union all
select REGR_sxy(COL_1,COL_1) from t_ustore_regr_sxy_010
union
select REGR_sxy(COL_2,COL_2) from t_ustore_regr_sxy_010
minus
select REGR_sxy(COL_2,COL_3) from t_ustore_regr_sxy_010) order by 1 limit 10;

select * from (
select REGR_sxy(COL_2,COL_3) from t_ustore_regr_sxy_010
union all
select REGR_sxy(COL_1,COL_1) from t_ustore_regr_sxy_010
union
select REGR_sxy(COL_2,COL_2) from t_ustore_regr_sxy_010
minus
select REGR_sxy(COL_2,COL_3) from t_ustore_regr_sxy_010) order by 1 limit 10;

select * from (
select REGR_sxy(COL_2,COL_3) from t_ustore_regr_sxy_010
union all
select REGR_sxy(COL_1,COL_1) from t_ustore_regr_sxy_010) order by 1 limit 10;

select * from (
select REGR_sxy(COL_2,COL_3) from t_ustore_regr_sxy_010
union all
select REGR_sxy(COL_1,COL_1) from t_ustore_regr_sxy_010
union
select REGR_sxy(COL_2,COL_2) from t_ustore_regr_sxy_010) order by 1 limit 10;

--step3:清理环境;expect:成功
drop sequence if exists seq_ustore_regr_sxy_010 cascade;
drop table if exists t_ustore_regr_sxy_010 cascade;